package com.furnitur.modules.admin.controller.order;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.furnitur.common.api.Result;
import com.furnitur.core.entity.order.Order;
import com.furnitur.modules.admin.dto.order.MerchantOrderQueryDTO;
import com.furnitur.modules.admin.service.order.MerchantOrderService;
import com.furnitur.modules.admin.vo.order.MerchantOrderStatisticsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/merchant/orders")
public class MerchantOrderController {
    
    @Autowired
    private MerchantOrderService merchantOrderService;
    
    @GetMapping
    public Result<IPage<Order>> list(MerchantOrderQueryDTO queryDTO) {
        return Result.success(merchantOrderService.getOrderList(queryDTO));
    }
    
    @GetMapping("/{orderNo}")
    public Result<Order> detail(@PathVariable String orderNo) {
        return Result.success(merchantOrderService.getOrderDetail(orderNo));
    }
    
    @PostMapping("/{orderNo}/ship")
    public Result<Void> ship(@PathVariable String orderNo, @RequestParam String trackingNo) {
        merchantOrderService.shipOrder(orderNo, trackingNo);
        return Result.success();
    }
    
    @GetMapping("/statistics")
    public Result<MerchantOrderStatisticsVO> statistics() {
        return Result.success(merchantOrderService.getOrderStatistics());
    }
} 